package com.zyd.handle;

import com.zyd.controller.result.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局处理异常类
 */
@ControllerAdvice
public class GlobalExceptionHandle extends RuntimeException{

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result error(Exception e){
        e.printStackTrace();
        System.out.println("自定义异常处理");
        return Result.fail().message("0不能作为除数");
    }

}


